package model

var RepositoryNames = struct { // repositories
	PromotionActivity       string
	PromotionRuleGroup      string
	PromotionRule           string
	PromotionCouponTemplate string
	PromotionCoupon         string
	PromotionMedia          string
}{
	PromotionActivity:       "Activity",
	PromotionRuleGroup:      "RuleGroup",
	PromotionRule:           "Rule",
	PromotionCouponTemplate: "CouponTemplate",
	PromotionCoupon:         "Coupon",
	PromotionMedia:          "PromotionMedia",
}

var RepositoryPreloadMap = map[string]map[string]string{
	RepositoryNames.PromotionActivity: {
		"Id":                    PromotionActivityColumns.ID,
		"Name":                  PromotionActivityColumns.Name,
		"Desc":                  PromotionActivityColumns.Description,
		"Members":               PromotionActivityColumns.MemberRestriction,
		"Type":                  PromotionActivityColumns.ActivityType,
		"Mutex":                 PromotionActivityColumns.MutexType,
		"Sort":                  PromotionActivityColumns.Sort,
		"Scope":                 PromotionActivityColumns.ScopeType,
		"TimesLimit":            PromotionActivityColumns.TimesLimit,
		"GroupMode":             PromotionActivityColumns.GroupMode,
		"GroupType":             PromotionActivityColumns.GroupType,
		"SeckillLimit":          PromotionActivityColumns.SeckillLimit,
		"SeckillCancelDuration": PromotionActivityColumns.SeckillCancelDuration,
		"SeckillNotifyDuration": PromotionActivityColumns.SeckillNotifyDuration,
		"PackageType":           PromotionActivityColumns.PackageType,
		"PackagePicId":          PromotionActivityColumns.PackagePicID,
		"PackagePicUrl":         PromotionActivityColumns.PackagePicURL,
		"Status":                PromotionActivityColumns.Status,
		"StartedAt":             PromotionActivityColumns.StartedAt,
		"EndedAt":               PromotionActivityColumns.EndedAt,
	},
	RepositoryNames.PromotionRuleGroup: {
		"Id": PromotionRuleGroupColumns.GroupID,
	},
	RepositoryNames.PromotionRule: {
		"Id": PromotionRuleColumns.RuleID,
	},
	RepositoryNames.PromotionCouponTemplate: {
		"Id":            PromotionCouponTemplateColumns.ID,
		"Name":          PromotionCouponTemplateColumns.Name,
		"Desc":          PromotionCouponTemplateColumns.Description,
		"Members":       PromotionCouponTemplateColumns.MemberRestriction,
		"Type":          PromotionCouponTemplateColumns.CouponType,
		"Mutex":         PromotionCouponTemplateColumns.MutexType,
		"Sort":          PromotionActivityColumns.Sort,
		"Scope":         PromotionCouponTemplateColumns.ScopeType,
		"Mode":          PromotionCouponTemplateColumns.Mode,
		"Threshhold":    PromotionCouponTemplateColumns.Threshhold,
		"DiscountMode":  PromotionCouponTemplateColumns.DiscountMode,
		"DiscountValue": PromotionCouponTemplateColumns.DiscountValue,
		"GemPrice":      PromotionCouponTemplateColumns.GemPrice,
		"Regions":       PromotionCouponTemplateColumns.Regions,
		"Count":         PromotionCouponTemplateColumns.Count,
		"PerLimit":      PromotionCouponTemplateColumns.PerLimit,
		"Remark":        PromotionCouponTemplateColumns.Remark,
		"ExpireMode":    PromotionCouponTemplateColumns.ExpireMode,
		"ExpireValue":   PromotionCouponTemplateColumns.ExpireValue,
		"StartedAt":     PromotionCouponTemplateColumns.StartedAt,
		"EndedAt":       PromotionCouponTemplateColumns.EndedAt,
		"Status":        PromotionCouponTemplateColumns.Status,
	},
	RepositoryNames.PromotionCoupon: {
		"Id":         PromotionCouponColumns.CouponID,
		"ActivityId": PromotionCouponColumns.ActivityID,
		"TemplateId": PromotionCouponColumns.TemplateID,
		"SourceType": PromotionCouponColumns.SourceType,
		"CouponCode": PromotionCouponColumns.CouponCode,
		"Code":       PromotionCouponColumns.CouponCode,
		"UserId":     PromotionCouponColumns.UserID,
		"OrderId":    PromotionCouponColumns.OrderID,
		"StartedAt":  PromotionCouponColumns.StartedAt,
		"EndedAt":    PromotionCouponColumns.EndedAt,
		"UsedAt":     PromotionCouponColumns.UsedAt,
		"Status":     PromotionCouponColumns.Status,
	},
	RepositoryNames.PromotionMedia: {
		"Uid":          PromotionAttachmentRelationshipColumns.AttachmentRelationshipID,
		"Id":           PromotionAttachmentRelationshipColumns.AttachmentID,
		"Uri":          PromotionAttachmentRelationshipColumns.AttachmentSource,
		"Url":          PromotionAttachmentRelationshipColumns.AttachmentImageURL,
		"Thumbnail":    PromotionAttachmentRelationshipColumns.AttachmentThumbnail,
		"Order":        PromotionAttachmentRelationshipColumns.AttachmentOrder,
		"altText":      PromotionAttachmentRelationshipColumns.AttachmentImageAlt,
		"sourceUrl":    PromotionAttachmentRelationshipColumns.AttachmentImageURL,
		"mediaDetails": PromotionAttachmentRelationshipColumns.AttachmentImageMeta, // Deprecated
		"metaData":     PromotionAttachmentRelationshipColumns.AttachmentImageMeta,
	},
}

var RpcEntityNames = struct { // rpc entities
	PromotionActivity       string
	PromotionRuleGroup      string
	PromotionRule           string
	PromotionCouponTemplate string
	PromotionCoupon         string
	PromotionMedia          string
	PromotionCouponMeta     string
}{
	PromotionActivity:       "activity",
	PromotionRuleGroup:      "ruleGroup",
	PromotionRule:           "rule",
	PromotionCouponTemplate: "couponTemplate",
	PromotionCoupon:         "coupon",
	PromotionMedia:          "promotionMedia",
	PromotionCouponMeta:     "promotionCouponMeta",
}

type ColumnSetting struct {
	Name          string // rpc column name
	RpcEntityName string // sqlboiler repository name
}

var RpcEntityPreloadMap = map[string]map[string]*ColumnSetting{
	RpcEntityNames.PromotionActivity: {
		"Group": &ColumnSetting{
			Name:          "Group",
			RpcEntityName: RpcEntityNames.PromotionRuleGroup,
		},
	},
	RpcEntityNames.PromotionRuleGroup:      {},
	RpcEntityNames.PromotionRule:           {},
	RpcEntityNames.PromotionCouponTemplate: {},
	RpcEntityNames.PromotionCoupon: {
		"Rule": &ColumnSetting{
			Name:          "Rule",
			RpcEntityName: RpcEntityNames.PromotionCouponTemplate,
		},
	},
	RpcEntityNames.PromotionMedia: {},
	RpcEntityNames.PromotionCouponMeta: {
		"mediaId": &ColumnSetting{ // ##25.03.17##
			Name: "_thumbnail_id",
		},
		"mediaUrl": &ColumnSetting{ // ##25.03.17##
			Name: "_thumbnail_url",
		},
	},
}
